home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / mortar_scripts.lua < prev    next >
Encoding:
Text File  |  2006-08-31  |  6.0 KB  |  174 lines

  1.  
  2. function units_mortar_setup()
  3.     units_setup(4,false,ENET_EFFECT_PS_SETUPSMOKE_SMALL,ENET_EFFECT_GEOMETRY_MORTARSHADOW)
  4. --    uniGetExecutor():addSimpleEffect(ENET_EFFECT_EXPERIMENTAL_SHIELD)
  5. --    uniGetExecutor():addSimpleEffect(862)
  6. end
  7.  
  8. function units_mortar_resetup()
  9.     units_setup(4,false,nul,ENET_EFFECT_GEOMETRY_MORTARSHADOW)
  10. end
  11.  
  12. function units_mortar_select()
  13.     units_select(22,2)
  14. end
  15.  
  16. function units_mortar_unselect()
  17.     units_unselect()
  18. end
  19.  
  20. function units_mortar_selectenemy()
  21.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  22. end
  23.  
  24. function units_mortar_damaged()
  25.     uniGetExecutor():applyDamage(uniGetLife())
  26. end
  27.  
  28. function units_mortar_highlight()
  29.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  30. end
  31.  
  32. function units_mortar_explode()
  33.     units_explode_small3()
  34. end
  35.  
  36. function units_mortar_move()
  37.     local unit = uniGetExecutor()
  38.     local sound = unit:play3DSound("mortar_move.wav",1)
  39.     local steps = {}
  40.     local i = 0;
  41.     for i = 0,1 do
  42.         steps[i] = unit:getBone(ENBT_STEPEMITTER,i):addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_LIGHTTANKSTEPSEMITTER)
  43.         steps[i+2] = unit:getBone(ENBT_STEPEMITTER,i):addSimpleEffect(ENET_EFFECT_PS_NEWTRACKSMOKE3)
  44.     end
  45.     units_rotateWheels()
  46.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 1.0))
  47.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_LINEAR,100))
  48.     sound:destroy()
  49.     unit:play3DSound("mortar_stop.wav",0):destroy()
  50.     for i = 0,1 do
  51.         if(unit:getScale() < 1.0) then 
  52.             steps[i]:destroy()
  53.         else
  54.             steps[i]:setTransformOwner()
  55.             steps[i]:suspendedDestroy(70)
  56.         end
  57.         steps[i+2]:suspendedDestroy(1.0)
  58.     end
  59.     units_stopWheels()
  60. end
  61.  
  62. function units_mortar_fire()
  63.     local unit = uniGetExecutor()
  64.     local gt = unit:getBone(ENBT_GUNTOWER)
  65.     gt:play3DSound("mortar_guntower_rotate.wav",0)
  66.  
  67.     local firespot = gt:getBone(ENBT_FIRE1)
  68.     local gun = gt:getBone(ENBT_GUN)
  69.  
  70.     local rot = gun:addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI / 1.5)
  71.     pause(0.25)
  72.     rot:destroy()
  73.  
  74.     waitDeath(gt:parabolicTargetting(uniGetTarget(),unit:getBone(ENBT_FIRE1)))
  75.  
  76.     gt:play3DSound("mortar_cannon_fire.wav",0):destroy()
  77.     local shot = firespot:addSimpleEffect(ENET_EFFECT_PS_NEWPLAZMABALL_FLY2)
  78.     firespot:addSimpleEffect(ENET_EFFECT_PS_DINOROBOTSHOT):suspendedDestroy(0.5)
  79.  
  80.     shot:executeCommand(ENC_FIRE1)
  81.     gt:gunRecoil(0,0.2,10)
  82.     pause(1.0)
  83.     gt:play3DSound("mortar_guntower_rotate.wav",0)
  84.     gun:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERDEFAULT,MATH_PI / 3.0)
  85.     gt:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERDEFAULT,MATH_PI)
  86.     unit:addFireArrow()
  87. end
  88.  
  89. registerCommand(ENSCRIPTSET_MORTAR,ENC_MOVE,"units_mortar_move")
  90. registerCommand(ENSCRIPTSET_MORTAR,ENC_FIRE1,"units_mortar_fire")
  91. registerCommand(ENSCRIPTSET_MORTAR,ENC_FIRE2,"units_mortar_fire")
  92. registerCommand(ENSCRIPTSET_MORTAR,ENC_SELECT,"units_mortar_select")
  93. registerCommand(ENSCRIPTSET_MORTAR,ENC_SELECTENEMY,"units_mortar_selectenemy")
  94. registerCommand(ENSCRIPTSET_MORTAR,ENC_UNSELECT,"units_mortar_unselect")
  95. registerCommand(ENSCRIPTSET_MORTAR,ENC_SETUP,"units_mortar_setup")
  96. registerCommand(ENSCRIPTSET_MORTAR,ENC_RESETUP,"units_mortar_resetup")
  97. registerCommand(ENSCRIPTSET_MORTAR,ENC_DAMAGED,"units_mortar_damaged")
  98. registerCommand(ENSCRIPTSET_MORTAR,ENC_EXPLODE,"units_mortar_explode")
  99. registerCommand(ENSCRIPTSET_MORTAR,ENC_HIGHLIGHT,"units_mortar_highlight")
  100. registerCommand(ENSCRIPTSET_MORTAR,ENC_INSIDE,"units_inside")
  101.  
  102. -- make description of unit
  103. desc = getEffectDescriptionP(ENET_UNIT_MORTAR)
  104. desc.ClassID = ENCLASS_MESHINSTANCE
  105. desc.EffectClassType = ENECT_GEOMETRY
  106. desc.FileName = "mortar.rmd"
  107. desc.ScriptSet = ENSCRIPTSET_MORTAR
  108. desc.MoveType = ENMOVE_GROUNDORIENTED
  109. desc.RenderType = ENRENDERTYPE_GEOMETRY
  110. desc.Material = ENMAT_RIGIDSKINNEDMESH
  111. desc.MaterialColors = units_materialcolors_human
  112.  
  113. -- shadow
  114. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_MORTARSHADOW)
  115. desc.ClassID = ENCLASS_MESHINSTANCE
  116. desc.EffectClassType = ENECT_GEOMETRY
  117. desc.FileName = "mortar_shadow.rmd"
  118. desc.RenderType = ENRENDERTYPE_SHADOW
  119. desc.Material = ENMAT_SHADOW
  120. desc.MaterialColors = units_materialcolors_shadow
  121.  
  122. -- register new unit to logic
  123. unitDesc = logic_getUnitDescP(4)
  124. unitDesc.group = 0
  125. unitDesc.order = 2
  126. unitDesc.unit_res_id = ENET_UNIT_MORTAR
  127. --unitDesc.unit_res_id = ENET_UNIT_LIGHTTANK_ALIEN
  128. unitDesc.unit_icon_id = "Mortar_h_small_normal.dds"
  129. unitDesc.active_id = "Mortar_h_small_active.dds"
  130. unitDesc.pressed_id = "Mortar_h_small_pressed.dds"
  131. unitDesc.big_icon_id = "Mortar_h_big_normal.dds"
  132. unitDesc.small_icon_id = "Mortar_u_stats.dds"
  133. unitDesc.HP = 4
  134. unitDesc.MP = 10
  135. unitDesc.WR = 2
  136. unitDesc.min_WR = 1
  137. unitDesc.WD = 2
  138. unitDesc.WR2 = 0
  139. unitDesc.min_WR2 = 0
  140. unitDesc.WD2 = 0
  141. unitDesc.ability = 0
  142. unitDesc.transport = 0
  143. unitDesc.value = 2
  144. unitDesc.race = 0
  145. unitDesc.fire_pause = 1.0
  146. unitDesc.move_pause = 0.7
  147. unitDesc.unit_info_scale = 0.06
  148. unitDesc.scn_name = "MORTAR"
  149.  
  150. ------------------------------------------------------------------------------------------------------
  151. ------------------------ effects related to unit------------------------------------------------------
  152. ------------------------------------------------------------------------------------------------------
  153.  
  154. function bullets_plazmaball_fire()
  155.     local bullet = uniGetExecutor()
  156.     bullet:setTransformOwner()
  157.     local light = bullet:addSimpleEffect(ENET_EFFECT_LIGHT_PLAZMABALLFLY)
  158.     local sound = bullet:play3DSound("mortar_plazmaball_fly.wav",1)
  159.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_PLAZMABALLFLY)
  160. --    waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_GRAVITYPARABOLA,150,uniGetTarget()))
  161.     waitDeath(bullet:parabolicFly(uniGetTarget()))
  162.     sound:destroy()
  163.     light:destroy()
  164.     track:suspendedDestroy(1.0)
  165.     bullet:play3DSound("mortar_plazmaball_explode.wav",0):destroy()
  166.     bullet:addSimpleEffect(ENET_EFFECT_LIGHT_PLAZMABALLEXPLODE):delayedDestroy(1.0)
  167.     bullet:addSimpleEffect(ENET_EFFECT_PS_PLAZMABALLEXPLODE):suspendedDestroy(1.0)
  168.     uniGetTarget():executeCommand(ENC_DAMAGED)
  169.     pause(1.0)
  170.     bullet:destroy()
  171. end
  172.  
  173. registerCommand(ENSCRIPTSET_BULLET_PLAZMABALL,ENC_FIRE1,"bullets_plazmaball_fire")
  174.